
import edu.tfg.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.Transaction;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Juarez
 */
public class ClienteDAOTeste {
    
    private Session sessao;
    private Transaction trans;
    
    public void salvar(ClienteTeste c){
        try{
        sessao =  HibernateUtil.getSessionFactory().openSession();
        trans = sessao.beginTransaction();
        /*
        Cliente cliente = new Cliente();
        cliente.setNome(c.getNome());
        cliente.setSenha(c.getSenha());
          */     
        sessao.save(c);
        trans.commit();
        }catch(Exception e){
            e.printStackTrace();
        }finally{
               sessao.close();
        }
   }
    
   public void removeCliente(ClienteTeste c){
       try{
        sessao =  HibernateUtil.getSessionFactory().openSession();
        trans = sessao.beginTransaction();
        
        sessao.delete(c);
        trans.commit();
       }catch(Exception e){
           e.printStackTrace();
       }finally{
           sessao.close();
       }
       
   }
    
    
}
